package com.sealer;

/**
 * 暴力法
 * Created by sealer on 17-5-23.
 */
public class ReverseString {
    public static void leftShiftOne(char[] s) {
        int length = s.length;
        char c = s[0];
        for (int i = 1; i < length; i++) {
            s[i - 1] = s[i];
        }
        s[length - 1] = c;
    }

    public static void leftRotateString (char[] s, int m) {
        while (m-- > 0) {
            leftShiftOne(s);
        }
    }

    public static void main(String[] args) {
        String s = "hello world!";
        char[] chars = s.toCharArray();
//        leftShiftOne(chars);
//        System.out.println(new String(chars));
        leftRotateString(chars, 4);
        System.out.println(new String(chars));
    }
}
